package settings;

import fileHandling.language.options.Controls;
import fileHandling.language.options.OptionValues;

import logic.nodes.nodeSettings.Settings;

import com.jme.input.KeyInput;

public class ControlSettings extends ConfigFile {
	
	private static ControlSettings settings = new ControlSettings();
	
	private ControlSettings() {
		super();
	}
	
	public static ControlSettings get() { return settings; }
	
	@Override
	public void reset() { settings = new ControlSettings(); }
	
	@Override
	public String getFileName() { return "controls.xml"; }
	
	@Override
	protected Settings getSettings() { return settings; }
	
	public int getForwardKey() { return getKey(getForwardString()); }
	public String getForwardString() { return getValueOf(Controls.Forward); }
	
	public int getBreakKey() { return getKey(getBreakString()); }
	public String getBreakString() { return getValueOf(Controls.Break); }
	
	public int getLeftKey() { return getKey(getLeftString()); }
	public String getLeftString() { return getValueOf(Controls.Left); }
	
	public int getRightKey() { return getKey(getRightString()); }
	public String getRightString() { return getValueOf(Controls.Right); }
	
	public int getOpenSpawnKey() { return getKey(getOpenSpawnString()); }
	public String getOpenSpawnString() { return getValueOf(Controls.Spawn_Menu); }
	
	public int getShowPlayersKey() { return getKey(getShowPlayersString()); }
	public String getShowPlayersString() { return getValueOf(Controls.Scoreboard); }
	
	public int getNearestTargetKey() { return getKey(getNearestTargetString()); }
	public String getNearestTargetString() { return getValueOf(Controls.Nearest_Target); }
	
	public int getBoostKey() { return getKey(getBoostString()); }
	public String getBoostString() { return getValueOf(Controls.Activate_Boost); }
	
	public boolean getMouseInverted() { return Boolean.valueOf(getMouseInvertedString()).booleanValue(); }
	public String getMouseInvertedString() { return getValueOf(Controls.Inverted_Mouse); }
	
	public float getMouseSensitivity() { return Float.valueOf(getMouseSensitivityString()).floatValue(); }
	public String getMouseSensitivityString() { return getValueOf(Controls.Mouse_Sensitivity); }
	
	public int getHeatseakerKey() { return getKey(getHeatseakerString()); }
	public String getHeatseakerString() { return getValueOf(Controls.Fire_Heatseaker); }
	
	public int getMissileKey() { return getKey(getMissileString()); }
	public String getMissileString() { return getValueOf(Controls.Fire_Missile); }
	
	public int getUseCounterMeasuresKey() { return getKey(getUseCounterMeasuresString());}
	public String getUseCounterMeasuresString() { return getValueOf(Controls.Use_Counter_Measures); }
	
	public int getUseRepairKitKey() { return getKey(getUseRepairKitString());}
	public String getUseRepairKitString() { return getValueOf(Controls.Use_Repairkit); }
	
	public int getUseShieldBatteryKey() { return getKey(getUseShieldBatteryString());}
	public String getUseShieldBatteryString() { return getValueOf(Controls.Use_Shieldbattery); }
	
	public int getChat() { return getKey(getChatString());}
	public String getChatString() { return getValueOf(Controls.Chat); }
	
	public int getTeamChat() { return getKey(getTeamChatString());}
	public String getTeamChatString() { return getValueOf(Controls.Team_Chat); }
	
	public int getSquadChat() { return getKey(getSquadChatString());}
	public String getSquadChatString() { return getValueOf(Controls.Squad_Chat); }
	
	public int getToggleMission() { return getKey(getToggleMissionString()); }
	public String getToggleMissionString() { return getValueOf(Controls.Toggle_Mission); }
	
	public boolean getHunterRotationReset() { return Boolean.valueOf(getHunterRotationResetString()).booleanValue(); }
	public String getHunterRotationResetString() { return getValueOf(Controls.Hunter_Rotation_Reset); }
	
	public int getShowMap() { return getKey(getShowMapString()); }
	public String getShowMapString() { return getValueOf(Controls.Show_Map); }
	
	public OptionValues getLookAround() { return OptionValues.valueOf(getValueOf(Controls.Look_Around)); }
	
	public OptionValues getFireEnergyWeapons() { return OptionValues.valueOf(getValueOf(Controls.Fire_Energy_Weapons)); }
	
	public int getKey(String keyString) {
		keyString = keyString.toUpperCase();
		if(keyString.equals("A")) return KeyInput.KEY_A;
		if(keyString.equals("B")) return KeyInput.KEY_B;
		if(keyString.equals("C")) return KeyInput.KEY_C;
		if(keyString.equals("D")) return KeyInput.KEY_D;
		if(keyString.equals("E")) return KeyInput.KEY_E;
		if(keyString.equals("F")) return KeyInput.KEY_F;
		if(keyString.equals("G")) return KeyInput.KEY_G;
		if(keyString.equals("H")) return KeyInput.KEY_H;
		if(keyString.equals("I")) return KeyInput.KEY_I;
		if(keyString.equals("J")) return KeyInput.KEY_J;
		if(keyString.equals("K")) return KeyInput.KEY_K;
		if(keyString.equals("L")) return KeyInput.KEY_L;
		if(keyString.equals("M")) return KeyInput.KEY_M;
		if(keyString.equals("N")) return KeyInput.KEY_N;
		if(keyString.equals("O")) return KeyInput.KEY_O;
		if(keyString.equals("P")) return KeyInput.KEY_P;
		if(keyString.equals("Q")) return KeyInput.KEY_Q;
		if(keyString.equals("R")) return KeyInput.KEY_R;
		if(keyString.equals("S")) return KeyInput.KEY_S;
		if(keyString.equals("T")) return KeyInput.KEY_T;
		if(keyString.equals("U")) return KeyInput.KEY_U;
		if(keyString.equals("V")) return KeyInput.KEY_V;
		if(keyString.equals("W")) return KeyInput.KEY_W;
		if(keyString.equals("X")) return KeyInput.KEY_X;
		if(keyString.equals("Y")) return KeyInput.KEY_Y;
		if(keyString.equals("Z")) return KeyInput.KEY_Z;
		if(keyString.equals("0")) return KeyInput.KEY_0;
		if(keyString.equals("1")) return KeyInput.KEY_1;
		if(keyString.equals("2")) return KeyInput.KEY_2;
		if(keyString.equals("3")) return KeyInput.KEY_3;
		if(keyString.equals("4")) return KeyInput.KEY_4;
		if(keyString.equals("5")) return KeyInput.KEY_5;
		if(keyString.equals("6")) return KeyInput.KEY_6;
		if(keyString.equals("7")) return KeyInput.KEY_7;
		if(keyString.equals("8")) return KeyInput.KEY_8;
		if(keyString.equals("9")) return KeyInput.KEY_9;
		if(keyString.equals("F1")) return KeyInput.KEY_F1;
		if(keyString.equals("F2")) return KeyInput.KEY_F2;
		if(keyString.equals("F3")) return KeyInput.KEY_F3;
		if(keyString.equals("F4")) return KeyInput.KEY_F4;
		if(keyString.equals("F5")) return KeyInput.KEY_F5;
		if(keyString.equals("F6")) return KeyInput.KEY_F6;
		if(keyString.equals("F7")) return KeyInput.KEY_F7;
		if(keyString.equals("F8")) return KeyInput.KEY_F8;
		if(keyString.equals("F9")) return KeyInput.KEY_F9;
		if(keyString.equals("F10")) return KeyInput.KEY_F10;
		if(keyString.equals("F11")) return KeyInput.KEY_F11;
		if(keyString.equals("F12")) return KeyInput.KEY_F12;
		if(keyString.equals("TAB")) return KeyInput.KEY_TAB;
		if(keyString.equals("SPACE")) return KeyInput.KEY_SPACE;
		if(keyString.equals("CTRL")) return KeyInput.KEY_LCONTROL;
		if(keyString.equals("SHIFT")) return KeyInput.KEY_LSHIFT;
		if(keyString.equals("<--")) return KeyInput.KEY_BACK;
		if(keyString.equals("UP")) return KeyInput.KEY_UP;
		if(keyString.equals("DOWN")) return KeyInput.KEY_DOWN;
		if(keyString.equals("LEFT")) return KeyInput.KEY_LEFT;
		if(keyString.equals("RIGHT")) return KeyInput.KEY_RIGHT;
		if(keyString.equals("ENTER")) return KeyInput.KEY_RETURN;
		return -1;
	}
}